<template>
  <div class="pagetools">
    <h3>社保</h3>
    <pagetools :showleft="true">
      <template #Left>自定义左侧内容</template>
      <template #right>自定义右侧内容</template>
    </pagetools>
    <myexcel></myexcel>
    <!-- 腾讯云测试 -->
    <input type="file" ref="myfile" @change="change" />
    <imgupload :imageUrl.sync="imageUrl"></imgupload>
  </div>
</template>

<script>
import COS from 'cos-js-sdk-v5'
export default {
  components: {
    mytools: () => import('../../components/PageTools/index')
  },
  data() {
    return {
      cos: null,
      imageUrl:
        'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2F945cad7c7105d352aa3c513c94846bb0c2f1a61342067-OWFZcE_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1640224094&t=1009d6a25c51bc6b50c6b7ac79f8b862'
    }
  },
  created() {
    this.cos = new COS({
      SecretId: 'AKIDXsxlJaaJlxrUrxmJZZJmytXuzoMcbIjt', // 身份识别 ID
      SecretKey: 'uXu2uUord9OM3TbT3MN9gvta091cw0nJ' // 身份密钥
    })
  },
  methods: {
    change() {
      console.log(this.$refs.myfile.files[0])
      this.cos.putObject(
        {
          Bucket: 'hr-1308447432' /* 必须 */,
          Region: 'ap-nanjing' /* 存储桶所在地域，必须字段 */,
          Key: this.$refs.myfile.files[0].name /* 必须 */,
          StorageClass: 'STANDARD',
          Body: this.$refs.myfile.files[0], // 上传文件对象
          onProgress: progressData => {
            // progressData: 上传过程中的实时进度对象
            console.log(JSON.stringify(progressData))
          }
        },
        (err, data) => {
          // data: 上传成功后的返回值
          // err: 上传出错的错误信息
          console.log(err || data)
          console.log('上传成功')
        }
      )
    }
  }
}
</script>

<style></style>
